class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

def max_path_sum(root):
    def dfs(node):
        if not node:
            return (float('-inf'), [])
        
        if not node.left and not node.right:
            return (node.val, [node.val])
        
        left_sum, left_path = dfs(node.left)
        right_sum, right_path = dfs(node.right)
        
        if left_sum > right_sum:
            return (left_sum + node.val, [node.val] + left_path)
        else:
            return (right_sum + node.val, [node.val] + right_path)
    
    max_sum, path = dfs(root)
    return max_sum, path

# 示例用法
# 构建一个二叉树
#       1
#      / \
#     2   3
#    / \
#   4   5
root = TreeNode(1)
root.left = TreeNode(2)
root.right = TreeNode(3)
root.left.left = TreeNode(4)
root.left.right = TreeNode(5)

max_sum, path = max_path_sum(root)
print("最大路径和:", max_sum)
print("路径:", path)